export default function waitForData(stream, cond = null) {
  return new Promise(resolve => {
    const listener = data => {
      if (cond ? cond(data) : true) {
        resolve(data)
        stream.removeListener('data', listener)
      }
    }
    stream.on('data', listener)
  })
}
